package com.weixin.engine.daily.guava;

public class Solution {

    public static void main(String[] args) {
//        System.out.println(Integer.parseInt("100", 2));
        System.out.println(Integer.toBinaryString(16000));
        System.out.println(Integer.toBinaryString(-16000));
        System.out.println(Long.toBinaryString(16000));
        System.out.println(Long.toBinaryString(-16000));
//        System.out.println(Math.max(1, 6));
//        System.out.println(addBinary("1010", "1011"));

//        System.out.println("11111111111111111111111111110000".length());

        char a = 127;
        char b =  1;
        int i = a + b;
        System.out.println(i);

    }

    public static String addBinary(String a, String b) {
//        return Integer.toBinaryString(
//                Integer.parseInt(a, 2) + Integer.parseInt(b, 2)
//        );

        StringBuilder ans = new StringBuilder();

        int n = Math.max(a.length(), b.length()), carry = 0;
        for (int i = 0; i < n; ++i) {

            int i1 = a.charAt(a.length() - 1 - i) - '0';
            int i2 = b.charAt(b.length() - 1 - i) - '0';

            carry += i < a.length() ? i1 : 0;
            carry += i < b.length() ? i2 : 0;
            ans.append((char) (carry % 2 + '0'));
            carry /= 2;
        }

        if (carry > 0) {
            ans.append('1');
        }
        ans.reverse();

        return ans.toString();
    }

}